2 // @name Press "." and do Quoting things on 4chanX
3 // @namespace http://tampermonkey.net/
5 // @description Allows you to quote text without creating a quote link item in your post
6 // @author ECHibiki - Sage
7 // @match *://boards.4chan.org/*
12 var THAT_FIELD_YOU_CHANGE_TO_SET_YOUR_HOTKEY_CHARACTER = ".";
18 document.addEventListener("keydown", function(e){
19 if(e.key == THAT_FIELD_YOU_CHANGE_TO_SET_YOUR_HOTKEY_CHARACTER && !(document.activeElement.tagName == "INPUT" || document.activeElement.tagName == "TEXTAREA")){
20 var text = getSelectionText().split("\n");
22 text = (text.map(function(line){return line.trim() != "" ? ">" + line : line;})).join("\n");
25 if(!qr_open) document.getElementsByClassName("qr-link")[0].click();
26 setTimeout(function(){
27 document.getElementById("qr").getElementsByTagName("TEXTAREA")[0].value += text + "\n";
35 function getSelectionText() {
37 if (window.getSelection) {
38 text = window.getSelection().toString();
39 } else if (document.selection && document.selection.type != "Control") {
40 text = document.selection.createRange().text;